home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
newsgroups
/
misc.19981211-19990422
/
000401_news@watsun.cc.columbia.edu _Tue Mar 23 10:16:15 1999.msg
< prev
next >
Wrap
Internet Message Format
|
1999-04-21
|
3KB
Return-Path: <news@watsun.cc.columbia.edu>
Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id KAA28085
for <kermit.misc@watsun.cc.columbia.edu>; Tue, 23 Mar 1999 10:16:14 -0500 (EST)
Received: (from news@localhost)
by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id KAA14437
for kermit.misc@watsun.cc.columbia.edu; Tue, 23 Mar 1999 10:00:22 -0500 (EST)
X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
From: dn5006@my-dejanews.com
Subject: Object-Oriented Programming in Kermit 95
Date: Tue, 23 Mar 1999 14:45:09 GMT
Organization: Deja News - The Leader in Internet Discussion
Message-ID: <7d89dj$tq3$1@nnrp1.dejanews.com>
To: kermit.misc@watsun.cc.columbia.edu
; OBJECT-ORIENTED PROGRAMMING IS VERY EFFECTIVE IN DESIGNING
; AND MAINTAINING SOFTWARE.
; KERMIT 95 PROVIDES MECHANISMS TO IMPLEMENT ELEGANTLY SOME
; OBJECT-ORIENTED FEATURES.
; THE FOLLOWING SCRIPT DEFINES A CLASS PERSON WITH TWO DATA
; ATTRIBUTES age, job AND TWO METHODS introduce, destroy.
; ALL DATA ATTRIBUTES AND METHODS ARE PUBLIC.
define person {
_assign \%1.age \%2
_assign \%1.job \%3
_assign \%1.introduce {
echo My name is \%1
echo I am \\m(\%1.age) years old
echo I am a \\m(\%1.job)
}
_assign \%1.destroy {
_define \%1.age
_define \%1.job
_define \%1.introduce
}
}
; RECENTLY I MET MARK, A 36 YEARS OLD TRUCK DRIVER
person mark 36 {truck driver}
; HE INTRODUCES HIMSELF
mark.introduce
; HE IS WITH HIS GIRL FRIEND, JANE, A 28 YEARS YOUNG SECRETARY
person jane 28 secretary
; SHE ALSO INTRODUCES HERSELF
jane.introduce
; THEY ARE OFF ON VACATION, I ERASE THEM FROM MY MEMORY
mark.destroy
jane.destroy
; FOLLOWING IS THE CLASS ANIMAL
define animal {
_assign \%1.sound \%2
_assign \%1.introduce {
echo I am a \%1 ... \\m(\%1.sound)
}
_assign \%1.destroy {
_define \%1.sound
_define \%1.introduce
}
}
; IN FRONT OF NY HOUSE, THERE ARE A DOG
animal dog wow
; AND A CAT
animal cat miaou
; THE DOG TRIES TO BE FRIENDLY
dog.introduce
; THE CAT REPLIES
cat.introduce
; I CLOSE THE WINDOW AND FORGET ABOUT THEM
dog.destroy
cat.destroy
; Different objects react differently to the same message, it's polymorphism!
; If you want to modify the behavior of all the objects in the same class,
; do it in the class definition, no need to browse through the code to update
; them. That's efficiency.
Dat Nguyen
Airline Telecommunications and Information Services
770 Sherbrooke West
Montreal, Quebec
Canada H3A 1G1
Email dat.nguyen&sita.int
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own